Repository navigation
Conversation
…Responses endpoints
Contributor
Author
|
Closing: held back from upstream for now and kept as a fork-side experiment/work-in-progress. It will be revisited later as a clean, standalone, CI-green PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
There is no way to point cli2api at an endpoint that already speaks OpenAI, Anthropic or Responses with just a base URL and a key, without going through a CLI worker or reverse proxy. Operators today have to either use a native provider family or run something else in front.
New API, LiteLLM and Cherry Studio all solve this the same way: a channel/provider is Base URL + key + protocol, the model list comes from
/modelsor is typed in, and the public model name is decoupled from the upstream one. This PR adds that as a first-class provider family instead of a new channel model, so priority, concurrency, proxy, cooldown and failover are reused as-is.What changed
customprovider family (internal/providers/custom/): one account is one endpoint. The credential (custom-api-v1) carriesbase_url,api_key, a wire protocol (openai|anthropic|responses|auto) and an optional manual model list. There is no child process, no CLI bundle and no reverse proxy.openaiposts to{base}/chat/completions,anthropicto{base}/messages,responsesto{base}/responses;autopicks per model from ananthropic/…orresponses/…prefix. Bare hosts get/v1, hosts that already carry/v1,/v4or/v1betaonly get the relative path appended, and a full path is used untouched.GET {base}/modelswith a 30-minute cache; a manual list replaces the catalog. A 404/405 on/modelswith a manual list still counts as ready, because that route is display-only.internal/translate/upstream_body.go,upstream_stream.go): builds request bodies for the three wires and converts their streams back to OpenAI chat deltas, including tool calls, so/v1/chat/completionsclients stream normally regardless of what sits behind the endpoint.custom-api-v1for export/import.What it does not change
ToolProfileForis not touched: upstream has no tool-profile table yet, and the profile forcustombelongs with the tool-profile work, not here.providers.Adapterthere is no liveness slot, so acustomaccount is maintained by the existing probe path.Tests
go build ./...go test ./internal/providers/custom/ ./internal/translate/ ./internal/providers/ ./internal/app/— all passinternal/providers/custom/custom_test.gocovers all three wires (path, auth header, body shape), SSE → chat-delta conversion, tool calls, base-URL normalisation, manual vs fetched catalog, and classification.